import hashlib
import random
import string

class Util:
    cert = "89e3d64646f0"

    @staticmethod
    def hash(data):
        sha256 = hashlib.sha256()
        if isinstance(data, str):
            data = data.encode('utf-8')
        sha256.update(data)
        
        return sha256.hexdigest()
    
    @staticmethod
    def generate_random_digi_string(length):
        characters = string.digits
        random_string = ''.join(random.choices(characters, k=length))
    
        return random_string
    
    @staticmethod
    def generate_random_char_string(length):
        characters = string.ascii_lowercase
        random_string = ''.join(random.choices(characters, k=length))
    
        return random_string

if __name__ == "__main__":
    print(Util.hash("3m")) # 生成1位数字和1位小写字母的密码hash
    print(Util.generate_random_char_string(8))